{% if user.is_authenticated %}
	<!DOCTYPE html>
	<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="icon" href="/static/favicon.ico">
		<meta name="description" content="">
		<meta name="keyword" content="">
		<meta name="author" content="">
		<title>VULSCAN</title>
		<link rel="stylesheet" href="/static/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="/static/style.css">		
	</head>
	<body>
	{% include 'header.html'%}
	{% include 'js.html' %}
	<div class="jumbotron text-center banner">
	  <p>
	  <h1 class="color-swatch">VulScan&nbsp;&nbsp;&nbsp;&nbsp;
	  <a class="btn btn-danger" role="button">{{ client_version }}版本</a> 
	  <!--<a class="btn btn-danger" href="javascript:alert('暂不提供');" role="button">v1.3下载</a>--></h1>
	  </p>

	  <div class="form-inline">  
	  <p>
	  <input id="url" class="form-control input-lg center-block" type="text" value="{{ url }}"  style="width: 50%"> &nbsp;
	  <button type="button" id="vulscan" class="btn btn-primary btn-lg" onclick="vulscan()" role="button">检测一下</button> &nbsp;
	  <a target="_blank" id="vulscan_report" class="btn btn-primary btn-lg" role="button" href="{% url 'vulscan_report' %}">查看报告</a>  
	  </p>
	  </div>
	</div>


	<!--# container start-->

	<div class="container">

	<div class="row">
		<div class="col-md-6">
		<div class="list-group">
		  <a href="{% url 'analysis' %}" class="list-group-item active">
		    漏洞分析模块  <span style="float:right">更多</span>
		  </a>
		  {% for v in poc_referer %}
		  <a href="{{v}}" class="list-group-item" target="_blank">{% if v %}{{ v | slice:"70" }} 
		  {% else %} 无漏洞分析 {% endif%}</a>
		  {% endfor %} 
		</div>
		</div>

		<div class="col-md-6">
		<div class="list-group">
		  <a href="{% url 'scan' %}" class="list-group-item active">
		    POC验证模块  <span style="float:right">更多</span>
		  </a>
		  {% for v in poc_data %}
		  <a href="{% url 'vul_scan' v.vulID %}" class="list-group-item" target="_blank">VULID_{{ v.vulID}}:{{ v.name}}</a>
		  {% endfor %} 
		</div>
		</div>
	</div>

	</div>
	<!-- container end -->
	{% include 'footer.html' %}
	<!-- 升级模态框 -->
	<div class="modal fade" style="margin:150px 0 0 auto;" id="update" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
					</button>
					<h4 class="modal-title" id="myModalLabel">
					升级提示!
					</h4>
				</div>
				<div class="modal-body">
					当前版本：{{ client_version }} 最新版本：{{ server_version }}
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>

	<script>
	$(window).load(function() { 
		//ajax获取接口最新版本
		main_version_api = window.location.protocol + '//' + window.location.host + "{% url 'main_version' %}";
		$.get(main_version_api, function(result){
		  update_str = Number(result);
		  //alert(update_str);
		  if (update_str == 0){
			//alert('更新');
			//alert(update_str);
			$('#update').modal({
				  keyboard: true
			   });		
		  }
		});
		//检测后台进度
		vulscan_jindu = self.setInterval("scan_jindu()",1000);
		//隐藏导出报告按钮
		$("#vulscan_report").hide(); 
	})  


	//vulscan 扫描函数
	function vulscan(){
		//alert('点击后按钮变成进度百分比，检测完毕增加导出报告按钮！');
		var url = $("#url").val();
		//var strRegex = /(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
		/*if(url!="")
		{
		 if (!strRegex.test(url)) { 
		    alert("请输入正确的url地址");
		   return false; 
		  }
		}*/
		ajax_url = window.location.protocol + "//" + window.location.host + "{% url 'vulscan' %}";
		//开始检测
		$.get(ajax_url+"?url="+url);
		//刷新进度条
		vulscan_jindu = self.setInterval("scan_jindu()",1000);

	}

	//进度条
	function scan_jindu(){
	  $("#vulscan_report").hide(); 
	  $.ajax({
	       url:window.location.protocol + '//' + window.location.host + "{% url 'vulscan_jindu' %}",
	       type:"GET",
	       success:function(data){//ajax返回的数据
	        var result = data;
	        //alert("width: "+result+"%");
	        //$('#vulscan').text(result+"%");
	        //添加进度条
	        if (result == 0){
	        	//没有任务
	        	self.clearInterval(vulscan_jindu);
	        	$('#vulscan').text("检测一下");
	            $('#vulscan').attr('disabled', false)
	            $('#url').attr('disabled', false)
	        }
	        else if (result<100){
	            $('#vulscan').attr('disabled', 'disabled')
	            $('#vulscan').text(result+"%");
	            $('#url').attr('disabled', 'disabled')
	        }
	        else if (result == 100) {//完成后 清空 ajax刷新计划
	            self.clearInterval(vulscan_jindu);
	            $('#vulscan').attr('disabled', false)
	            $('#vulscan').text("检测一下"); 
	            $("#vulscan_report").show(); 
	            $('#url').attr('disabled', false)
	          }
	         },
	       });
	}
	//显示结果和导出结果按钮
	</script>

	</body>
	</html>
{% else %}
<script>window.location.href="{% url 'login' %}";</script> 
{% endif %}

